<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" href="./asset/css/reset.css">
  <link rel="stylesheet" href="./asset/css/personal-summary.css">
  <title>李山投资-试用期期满自评</title>
</head>

<body>
  <div class="wrapper">
    <p class="works">
      <button id="submit" class="works__btn">提交</button>
      <button id="download" class="works__btn">导出</button>
    </p>
    <div id="pdf">
      <p class="logo">
        <img src="./asset/images/logo.png" alt="" width="210px" height="53px">
      </p>
      <form class="main">
        <h1 class="title">试用期期满自评<span class="tip">LSHR-03-C</span></h1>
        <div class="sheet">
          <div class="sheet__line l1">
            按要求填表，并在”员工自评“栏对该任务作以下五个评价
          </div>
          <div class="sheet__line l2 clearfix">
            <div class="sheet__item">A.优秀完成</div>
            <div class="sheet__item">B.较好完成</div>
            <div class="sheet__item">C.基本完成</div>
            <div class="sheet__item">D.未完成</div>
            <div class="sheet__item">E.基本未对应</div>
          </div>
          <div class="sheet__content clearfix">
            <div class="sheet__content__column c1">
              <span class="vertical-text">
                绩效表现
              </span>
            </div>
            <div class="sheet__content__column c2">
              <h2>指派工作</h2>
              <div class="text--wrapper">
                <div class="sheet__content--text">
                  <textarea class="textarea" id="assign1" name="assign1" placeholder="请填写指派工作（限60字）" maxlength="60"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="assign2" name="assgin2" placeholder="请填写指派工作（限60字）" maxlength="60"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="assign3" name="assgin3" placeholder="请填写指派工作（限60字）" maxlength="60"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="assign4" name="assgin4" placeholder="请填写指派工作（限60字）" maxlength="60"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="assign5" name="assgin5" placeholder="请填写指派工作（限60字）" maxlength="60"></textarea>
                </div>
              </div>
            </div>
            <div class="sheet__content__column c3">
              <h2>达成标准（详细描述）</h2>
              <div class="text--wrapper">
                <div class="sheet__content--text">
                  <textarea class="textarea" id="standard1" name="standard1" placeholder="请填写达成标准（限210字）" maxlength="210"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="standard2" name="standard2" placeholder="请填写达成标准（限210字）" maxlength="210"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="standard3" name="standard3" placeholder="请填写达成标准（限210字）" maxlength="210"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="standard4" name="standard4" placeholder="请填写达成标准（限210字）" maxlength="210"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="standard5" name="standard5" placeholder="请填写达成标准（限210字）" maxlength="210"></textarea>
                </div>
              </div>
            </div>
            <div class="sheet__content__column c4">
              <h2>员工自评</h2>
              <div class="text--wrapper">
                <div class="sheet__content--text">
                  <textarea class="textarea" id="selfAssess1" name="selfAssess1" placeholder="请填写员工自评（限99字）" maxlength="99"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="selfAssess2" name="selfAssess2" placeholder="请填写员工自评（限99字）" maxlength="99"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="selfAssess3" name="selfAssess3" placeholder="请填写员工自评（限99字）" maxlength="99"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="selfAssess4" name="selfAssess4" placeholder="请填写员工自评（限99字）" maxlength="99"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="selfAssess5" name="selfAssess5" placeholder="请填写员工自评（限99字）" maxlength="99"></textarea>
                </div>
              </div>
            </div>
            <div class="sheet__content__column c5">
              <h2>上级评价</h2>
              <div class="text--wrapper">
                <div class="sheet__content--text">
                  <textarea class="textarea" id="leaderAssess1" name="leaderAssess1" placeholder="请填写上级评价（限99字）" maxlength="99"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="leaderAssess2" name="leaderAssess2" placeholder="请填写上级评价（限99字）" maxlength="99"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="leaderAssess3" name="leaderAssess3" placeholder="请填写上级评价（限99字）" maxlength="99"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="leaderAssess4" name="leaderAssess4" placeholder="请填写上级评价（限99字）" maxlength="99"></textarea>
                </div>
                <div class="sheet__content--text">
                  <textarea class="textarea" id="leaderAssess5" name="leaderAssess5" placeholder="请填写上级评价（限99字）" maxlength="99"></textarea>
                </div>
              </div>
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
</body>
<script src="./js/jquery-1.8.3.min.js"></script>
<script>
  // var url = window.location.href;
  // url = url.replace(/type=edit/, 'type=preview');
  // console.log(url)
  var type = /type=(\w+)/gi.exec(window.location.href);
  var empid = /empid=(\w+)/gi.exec(window.location.href);
  var username = /username=([\u4E00-\u9FA5]+)/gi.exec(decodeURIComponent(window.location.href));
  var station = /station=([\u4E00-\u9FA5]+)/gi.exec(decodeURIComponent(window.location.href));
  // var baseUrl = 'http://192.168.22.45:5526/';
  // var baseUrl = 'http://192.168.3.26:5526/';
  var baseUrl = 'http://report.wsloan.com:5526/EmployeeSystem';

  if (username) {
    username = username[1];
  }

  if (station) {
    station = station[1];
  }
  if (empid) {
    empid = empid[1];
  } else {
    // 没有empid的处理
  }
  if (type) {
    type = type[1];
    if (type == 'edit') {
      // $('#uname').val(username)
      $('#submit').show();
    } else if (type == 'preview') {
      $('.input,.radio,.textarea').attr('disabled', 'true');
      $('#download').show();
      getSummary();
    } else {
      // 非法参数值处理
    }
  } else {
    // 没有type的处理
  }

  function getSummary(){
    $.ajax({
      url: baseUrl + 'show/trial.htmls',
      type:'get',
      data: {
        empid: empid
      },
      success: function(res){
        var data = res.data
        if(res.code === 0 && data){
          $('#assign1').val(data.assignWork1 || ' ');
          $('#standard1').val(data.standard1 || ' ');
          $('#selfAssess1').val(data.selfAss1 || ' ');
          $('#leaderAssess1').val(data.leaderAss1 || ' ');

          $('#assign2').val(data.assignWork2 || ' ');
          $('#standard2').val(data.standard2 || ' ');
          $('#selfAssess2').val(data.selfAss2 || ' ');
          $('#leaderAssess2').val(data.leaderAss2 || ' ');

          $('#assign3').val(data.assignWork3 || ' ');
          $('#standard3').val(data.standard3 || ' ');
          $('#selfAssess3').val(data.selfAss3 || ' ');
          $('#leaderAssess3').val(data.leaderAss3 || ' ');

          $('#assign4').val(data.assignWork4 || ' ');
          $('#standard4').val(data.standard4 || ' ');
          $('#selfAssess4').val(data.selfAss4 || ' ');
          $('#leaderAssess4').val(data.leaderAss4 || ' ');

          $('#assign5').val(data.assignWork5 || ' ');
          $('#standard5').val(data.standard5 || ' ');
          $('#selfAssess5').val(data.selfAss5 || ' ');
          $('#leaderAssess5').val(data.leaderAss5 || ' ');
        }
      },
      error: function(res){
        alert('请求失败')
      }
    })
  }

  // 提交
  $('#submit').on('click', function(e) {
    e.stopPropagation();
    e.preventDefault();

    var assignWork1 = $('#assign1').val()
    var assignWork2 = $('#assign2').val()
    var assignWork3 = $('#assign3').val()
    var assignWork4 = $('#assign4').val()
    var assignWork5 = $('#assign5').val()
    var standard1 = $('#standard1').val()
    var standard2 = $('#standard2').val()
    var standard3 = $('#standard3').val()
    var standard4 = $('#standard4').val()
    var standard5 = $('#standard5').val()
    var selfAss1 = $('#selfAssess1').val()
    var selfAss2 = $('#selfAssess2').val()
    var selfAss3 = $('#selfAssess3').val()
    var selfAss4 = $('#selfAssess4').val()
    var selfAss5 = $('#selfAssess5').val()
    var leaderAss1 = $('#leaderAssess1').val()
    var leaderAss2 = $('#leaderAssess2').val()
    var leaderAss3 = $('#leaderAssess3').val()
    var leaderAss4 = $('#leaderAssess4').val()
    var leaderAss5 = $('#leaderAssess5').val()

    if (!(assignWork1 && standard1 && selfAss1 && leaderAss1) &&
      !(assignWork2 && standard2 && selfAss2 && leaderAss2) &&
      !(assignWork3 && standard3 && selfAss3 && leaderAss3) &&
      !(assignWork4 && standard4 && selfAss4 && leaderAss4)
    ) {
      alert('还有未填写的项目');
      return false;
    }
    console.log({
        empid: empid,
        assignWork1: assignWork1,
        assignWork2: assignWork2,
        assignWork3: assignWork3,
        assignWork4: assignWork4,
        assignWork5: assignWork5,
        standard1: standard1,
        standard2: standard2,
        standard3: standard3,
        standard4: standard4,
        standard5: standard5,
        selfAss1: selfAss1,
        selfAss2: selfAss2,
        selfAss3: selfAss3,
        selfAss4: selfAss4,
        selfAss5: selfAss5,
        leaderAss1: leaderAss1,
        leaderAss2: leaderAss2,
        leaderAss3: leaderAss3,
        leaderAss4: leaderAss4,
        leaderAss5: leaderAss5,
      });
    $.ajax({
      url: baseUrl + 'insert/emp/check.htmls',
      type: 'post',
      dataType: 'json',
      data: {
        empid: empid,
        assignWork1: assignWork1,
        assignWork2: assignWork2,
        assignWork3: assignWork3,
        assignWork4: assignWork4,
        assignWork5: assignWork5,
        standard1: standard1,
        standard2: standard2,
        standard3: standard3,
        standard4: standard4,
        standard5: standard5,
        selfAss1: selfAss1,
        selfAss2: selfAss2,
        selfAss3: selfAss3,
        selfAss4: selfAss4,
        selfAss5: selfAss5,
        leaderAss1: leaderAss1,
        leaderAss2: leaderAss2,
        leaderAss3: leaderAss3,
        leaderAss4: leaderAss4,
        leaderAss5: leaderAss5,
      },
      success: function(data) {
        // console.log(data);
        var url = window.location.href
        if (data.code === 0) {
          alert(data.msg);
          url = url.replace(/type=edit/, 'type=preview');
          window.location.replace(url)
        }
      },
      error: function(error) {
        console.log(error);
        alert('请求失败');
      }
    });
  });
</script>
<script src="./js/jspdf.debug.js"></script>
<!-- <script src="./js/jspdf.min.js"></script> -->
<script src="./js/download.js"></script>

</html>
